using System;
using System.Data;
using System.Web; 
using System.Web.UI;
using System.Web.UI.WebControls;

/// <summary>
/// Summary description for GridViewHelper
/// </summary>
public class GridViewHelper
{
    public void FillDataTableToGridView(
    DataTable dataTable, GridView gridView)
    {                          
        if (dataTable != null)
        {
            gridView.DataSource = dataTable;
        }
        else
            gridView.DataSource = null;
        gridView.DataBind();
    }
    public void FillDataViewToGridView(
    DataView dataView, GridView gridView)
    {
        if (dataView != null)
        {
            gridView.DataSource = dataView;
        } 
        else
            gridView.DataSource = null;
        gridView.DataBind();
    }
    
    public void FillDataTableToGridView(
    DataTable dataTable, GridView gridView, 
    int pageSize, int pageCount, 
    PagerButtons pagerButtons )
    {
        
        gridView.AllowPaging = true;                
        if (dataTable != null)
        {
            gridView.DataSource = dataTable;
            gridView.PageSize = pageSize;
            gridView.PagerSettings.PageButtonCount= pageCount;
            gridView.PagerSettings.Mode = pagerButtons;
        }
        else
           gridView.DataSource = null; 
        gridView.DataBind();
    }
     
    public void FillDataViewToGridView(
    DataView dataView, GridView gridView,
    int pageSize, int pageCount,
    PagerButtons pagerButtons)
    {

        gridView.AllowPaging = true;
        if (dataView != null)
        {
            gridView.DataSource = dataView;
            gridView.PageSize = pageSize;
            gridView.PagerSettings.PageButtonCount = pageCount;
            gridView.PagerSettings.Mode = pagerButtons;
        }
        else
            gridView.DataSource = null;
        gridView.DataBind();
    }
}
